#pragma once

#include <windows.storage.streams.h>
using namespace Platform;
using namespace Windows::Storage;
using namespace Windows::Storage::Streams;

const int DL_BUFFER_SIZE = 1024 * 1024;

// Helper method to handle failed HRESULT
inline void ThrowIfFailed(HRESULT hr)
{
	if (FAILED(hr))
	{
		// Create an exception corresponding to the HRESULT error code
		throw Platform::Exception::CreateException(hr);
	}
}

HRESULT ReadFloatMetadata(IWICMetadataQueryReader* reader, LPCWSTR metadataName, float &value);
HRESULT ReadBoolMetadata(IWICMetadataQueryReader* reader, LPCWSTR metadataName, bool &value);
HRESULT ReadUIntegerMetadata(IWICMetadataQueryReader* reader, LPCWSTR metadataName, UINT &value);
HRESULT ReadUCharMetadata(IWICMetadataQueryReader* reader, LPCWSTR metadataName, UINT &value);

IStream* createIStreamFromIBuffer(Streams::IBuffer ^buffer);
